﻿using BackData;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Rabbit.API.Application.Command.Kill;
using Rabbit.API.DTOs;

namespace Rabbit.API.Controllers
{
    /// <summary>
    /// 屠宰控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class KillsController : ControllerBase
    {
        IMediator mediator;

        public KillsController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取屠宰详情
        /// </summary>
        /// <param name="request">参数</param>
        /// <param name="cancellationToken">取消</param>
        /// <returns>屠宰详情</returns>
        [HttpGet]
        public Task<APIResult<KillDTO>> KillGet([FromQuery]KillGetCommand request)
        {
            try
            {
                return mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 屠宰信息修改
        /// </summary>
        /// <param name="request">参数</param>
        /// <param name="cancellationToken">取消</param>
        /// <returns>影响行数</returns>
        [HttpPut]
        public async Task<APIResult<int>> KillUpdate(KillUpdateCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
